var co = require('co');
var seqModule = require('../../../routes/createModules');
var seq = new seqModule();
var util = require('../../../common/util');

//met一周直播
var signUpController = {
    addSignUp: function (req, res) {
        var memberId = req.query.memberId;
        var liveId = req.query.liveId;
        var paramT = {};
        paramT.memberId = memberId;
        paramT.liveId = liveId;
        seq.signupLogModule.count({ where: paramT }).then(function (signCount) {
            if (signCount == 0) {
                req.query.id = util.getUUID();
                req.query.createTime = util.getNowTime();
                seq.signupLogModule.create(req.query).then(function (result) {
                    res.json({ 'success': true, 'msg': '添加成功！', "result": result });
                }).catch(function (err) {
                    res.json({ 'success': false, 'msg': '添加失败' });
                    console.log(err);
                })
            } else {
                res.json({ 'success': false, 'msg': '该用户已报名！' });
            }
        }).catch(function (err) {
            res.json({ 'success': false, 'msg': '查询数量失败' });
            console.log(err);
        })
    }
}
module.exports = signUpController;